<?php
    session_start();

    if (!isset($_POST['submit'])) {
        $_SESSION['score'] = 0;
    }
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <?php
    // be my guest: http://www.w3schools.com/tags/
    $validTags = '!-- -- !doctype a html head body div span';

    $tags = explode(' ', $validTags);
    $isValid = false;

    if(array_search($_POST['tag'], $tags)){
        $isValidTag = true;
        $_SESSION['score']++;
    } else {
        $isValidTag = false;
    }

    if ($isValid) {
        $result = "Valid HTML Tag! \n Score: {$_SESSION['score']}";
    }
    ?>
</head>
<body>
<form action="input-counter-with-session.php" method="post">
    <label for="tag">Enter tag:</label>
    <input type="text" name="tag">
    <input type="submit" name="submit" value="Submit">
</form>
<?php
if (isset($result)) {
    echo $result;
}
?>
</body>
</html>